package com.example.mapper;
import com.example.entity.Course;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface CourseMapper {

    @Insert("INSERT INTO courses (user_id, course_name, course_time, location, assignment_deadline, exam_date) " +
            "VALUES (#{userId}, #{courseName}, #{courseTime}, #{location}, #{assignmentDeadline}, #{examDate})")
    int insertCourse(Course course);

    @Delete("DELETE FROM courses WHERE course_id = #{courseId}")
    int deleteCourseById(Integer courseId);

    @Update("UPDATE courses SET course_name = #{courseName}, course_time = #{courseTime}, location = #{location}, " +
            "assignment_deadline = #{assignmentDeadline}, exam_date = #{examDate} WHERE course_id = #{courseId}")
    int updateCourse(Course course);

    @Select("SELECT * FROM courses WHERE user_id = #{userId}")
    List<Course> getCoursesByUserId(Integer userId);
}
